import requests,json

# data = {
#     'username':'125',
#     'phone_number':'18818888866'
#     # 'password':'18818888866'
# }
# data_json = json.dumps(data)
response  = requests.post("http://127.0.0.1:5000/api/getWordsHight")
response.enconding = "utf-8"
print(response.text)

# data=[{"child_list":[{"class_id":"5544","word_num":"21","title":"Student Book 1","course_num":"2"},{"class_id":"11130","word_num":"42","title":"Student Book 2","course_num":"3"},{"class_id":"2926","word_num":"11","title":"Student Book 3","course_num":"1"},{"class_id":"7476","word_num":"28","title":"Student Book 4","course_num":"2"},{"class_id":"4020","word_num":"15","title":"Student Book 5","course_num":"1"},{"class_id":"5380","word_num":"20","title":"Student Book 6","course_num":"1"},{"class_id":"8910","word_num":"33","title":"Student Book 7","course_num":"2"},{"class_id":"11111","word_num":"41","title":"Student Book 8","course_num":"3"}],"word_num":"211","title":"河北版小学英语","course_num":"15"},{"child_list":[{"class_id":"99408","word_num":"152","title":"第一册","course_num":"8"},{"class_id":"93010","word_num":"142","title":"第二册","course_num":"8"},{"class_id":"24272","word_num":"37","title":"第三册","course_num":"2"},{"class_id":"32193","word_num":"49","title":"第四册","course_num":"3"},{"class_id":"7548","word_num":"51","title":"第五册","course_num":"3"},{"class_id":"9387","word_num":"63","title":"第六册","course_num":"4"},{"class_id":"8400","word_num":"56","title":"第七册","course_num":"3"},{"class_id":"11627","word_num":"77","title":"第八册","course_num":"4"},{"class_id":"15912","word_num":"104","title":"第九册","course_num":"6"},{"class_id":"23716","word_num":"154","title":"第十册","course_num":"8"},{"class_id":"22010","word_num":"142","title":"第十一册","course_num":"8"}],"word_num":"1027","title":"小学深圳版","course_num":"57"},{"child_list":[{"class_id":"5146","word_num":"83","title":"一年级 上学期","course_num":"5"},{"class_id":"3213","word_num":"51","title":"一年级 下学期","course_num":"3"},{"class_id":"3264","word_num":"51","title":"二年级 上学期","course_num":"3"},{"class_id":"3835","word_num":"59","title":"二年级 下学期","course_num":"3"},{"class_id":"4950","word_num":"75","title":"三年级 上学期","course_num":"4"},{"class_id":"4623","word_num":"69","title":"三年级 下学期","course_num":"4"},{"class_id":"4624","word_num":"68","title":"四年级 上学期","course_num":"4"},{"class_id":"6693","word_num":"97","title":"四年级 下学期","course_num":"5"},{"class_id":"5810","word_num":"83","title":"五年级 上学期","course_num":"5"},{"class_id":"5183","word_num":"73","title":"五年级 下学期","course_num":"4"},{"class_id":"19800","word_num":"275","title":"六年级 上学期","course_num":"14"},{"class_id":"13286","word_num":"182","title":"六年级 下学期","course_num":"10"}],"word_num":"1166","title":"小学牛津版","course_num":"64"}]
# for i in data:
#     for j in i['child_list']:
#         print(str(j)+",")
# import requests
# import json,random
# class_id =[
#         {"class_id": "30302", "word_num": "278", "title": "必修1", "course_num": "14"},
#         {"class_id": "29150", "word_num": "265", "title": "必修2", "course_num": "14"},
#         {"class_id": "40182", "word_num": "362", "title": "必修3", "course_num": "19"},
#         {"class_id": "33488", "word_num": "299", "title": "必修4", "course_num": "15"}, 
#         {"class_id": "38872", "word_num": "344", "title": "必修5", "course_num": "18"},
#         {"class_id": "45045", "word_num": "385", "title": "选修6", "course_num": "20"}, 
#         {"class_id": "44722", "word_num": "379", "title": "选修7", "course_num": "19"},
#         {"class_id": "18650", "word_num": "373", "title": "高一 上学期", "course_num": "19"},
#         {"class_id": "25143", "word_num": "493", "title": "高一 下学期", "course_num": "25"}, 
#         {"class_id": "24388", "word_num": "469", "title": "高二 上学期", "course_num": "24"}, 
#         {"class_id": "21094", "word_num": "398", "title": "高二 下学期", "course_num": "20"},
#         {"class_id": "26460", "word_num": "490", "title": "高三 上学期", "course_num": "25"}, 
#         {"class_id": "24420", "word_num": "444", "title": "高三 下学期", "course_num": "23"}
# {'class_id': '5544', 'word_num': '21', 'title': 'Student Book 1', 'course_num': '2'},
# {'class_id': '11130', 'word_num': '42', 'title': 'Student Book 2', 'course_num': '3'},
# {'class_id': '2926', 'word_num': '11', 'title': 'Student Book 3', 'course_num': '1'},
# {'class_id': '7476', 'word_num': '28', 'title': 'Student Book 4', 'course_num': '2'},
# {'class_id': '4020', 'word_num': '15', 'title': 'Student Book 5', 'course_num': '1'},
# {'class_id': '5380', 'word_num': '20', 'title': 'Student Book 6', 'course_num': '1'},
# {'class_id': '8910', 'word_num': '33', 'title': 'Student Book 7', 'course_num': '2'},
# {'class_id': '11111', 'word_num': '41', 'title': 'Student Book 8', 'course_num': '3'},
# {'class_id': '99408', 'word_num': '152', 'title': '第一册', 'course_num': '8'},
# {'class_id': '93010', 'word_num': '142', 'title': '第二册', 'course_num': '8'},
# {'class_id': '24272', 'word_num': '37', 'title': '第三册', 'course_num': '2'},
# {'class_id': '32193', 'word_num': '49', 'title': '第四册', 'course_num': '3'},
# {'class_id': '7548', 'word_num': '51', 'title': '第五册', 'course_num': '3'},
# {'class_id': '9387', 'word_num': '63', 'title': '第六册', 'course_num': '4'},
# {'class_id': '8400', 'word_num': '56', 'title': '第七册', 'course_num': '3'},
# {'class_id': '11627', 'word_num': '77', 'title': '第八册', 'course_num': '4'},
# {'class_id': '15912', 'word_num': '104', 'title': '第九册', 'course_num': '6'},
# {'class_id': '23716', 'word_num': '154', 'title': '第十册', 'course_num': '8'},
# {'class_id': '22010', 'word_num': '142', 'title': '第十一册', 'course_num': '8'},
# {'class_id': '5146', 'word_num': '83', 'title': '一年级 上学期', 'course_num': '5'},
# {'class_id': '3213', 'word_num': '51', 'title': '一年级 下学期', 'course_num': '3'},
# {'class_id': '3264', 'word_num': '51', 'title': '二年级 上学期', 'course_num': '3'},
# {'class_id': '3835', 'word_num': '59', 'title': '二年级 下学期', 'course_num': '3'},
# {'class_id': '4950', 'word_num': '75', 'title': '三年级 上学期', 'course_num': '4'},
# {'class_id': '4623', 'word_num': '69', 'title': '三年级 下学期', 'course_num': '4'},
# {'class_id': '4624', 'word_num': '68', 'title': '四年级 上学期', 'course_num': '4'},
# {'class_id': '6693', 'word_num': '97', 'title': '四年级 下学期', 'course_num': '5'},
# {'class_id': '5810', 'word_num': '83', 'title': '五年级 上学期', 'course_num': '5'},
# {'class_id': '5183', 'word_num': '73', 'title': '五年级 下学期', 'course_num': '4'},
# {'class_id': '19800', 'word_num': '275', 'title': '六年级 上学期', 'course_num': '14'},
# {'class_id': '13286', 'word_num': '182', 'title': '六年级 下学期', 'course_num': '10'}
        # ]
# chiose=class_id[random.randint(0, len(class_id)-1)]
# url="http://rw.ylapi.cn/reciteword/wordlist.u?uid=11551&appkey=111a8e9c15660760a272ca26335b5b35&class_id=%s&course=%s"%(chiose['class_id'],random.randint(1,int(chiose['course_num'])))
# response  = requests.post(url)
# response.enconding = "utf-8"
# result_data=json.loads(response.text)
# print(result_data['datas'])

# import os
# from PIL import Image, ImageFont, ImageDraw
 
 
# def getImg(text):
#     result=''
#     for i in range(len(text)):
#         if i%5==0:
#             result+='\n'
#         result+=text[i]
#     print(result)
#     im = Image.new("RGB", (100, 100), (255, 255, 255))
#     dr = ImageDraw.Draw(im)
#     font = ImageFont.truetype(os.path.join("fonts", "simsun.ttc"), 18)
#     dr.text((10, 5), result, font=font, fill="#000000")
#     return im

# def return_img_stream(img_local_path):
#   """
#   工具函数:
#   获取本地图片流
#   :param img_local_path:文件单张图片的本地绝对路径
#   :return: 图片流
#   """
#   import base64
#   img_stream = ''
#   with open(img_local_path, 'r') as img_f:
#     img_stream = img_f.read()
#     img_stream = base64.b64encode(img_stream)
#   return img_stream

# print(return_img_stream(getImg('qweqw')))

# from flask import Flask, jsonify
# from multiprocessing import Value

# counter = Value('i', 0)
# app = Flask(__name__)

# @app.before_request
# def count():
#     with counter.get_lock():
#         counter.value += 1
        
# @app.route('/')
# def index():
#     return jsonify(count=counter.value)

# app.run(processes=True)
